package com.muse.springbootdemo.service;

import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.annotation.PartitionOffset;
import org.springframework.kafka.annotation.TopicPartition;
import org.springframework.stereotype.Service;

import com.muse.springbootdemo.entity.Message;

import lombok.extern.slf4j.Slf4j;

/**
 * @description
 * @author: muse
 **/
@Slf4j
@Service
public class ConsumerService {

    private final static String TOPIC_NAME = "muse-rp";
    private final static String CONSUMER_GROUP_NAME = "museGroup";

    /**
     * 消息消费演示
     */
    @KafkaListener(topics = TOPIC_NAME, groupId = CONSUMER_GROUP_NAME)
    public void listenGroup(ConsumerRecord<String, Message> record) {
        log.info(" [topic]={}, [partition]={}, [offset]={}, [value]={}", record.topic(), record.partition(),
                record.offset(), record.value());
    }

}
